<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>货品基础信息管理</title>
	<meta name="decorator" content="default"/>
	<script type="text/javascript">
		$(document).ready(function() {
			
		});
		function page(n,s){
			$("#pageNo").val(n);
			$("#pageSize").val(s);
			$("#searchForm").submit();
        	return false;
        }
		function clearForm(){
			$("#supplierId").val('');
			$("#categoryId").val('');
			$("#searchForm").submit();
        	return false;
		}
		
		var check_val = [];
		//全选
		function selectAll(n){
			
			if(n.checked){
				check_val = []
				$("input[type=checkbox]").each(function(i,n) {
					if(i>0){
						this.checked = true; 
				        check_val.push(n.value)
					}
		        });  
			}else{
				$("input[type=checkbox]").each(function(i,n) {  
		            this.checked = false; 
		            check_val = []
		        });
			}
		}
		//单选
		function check(n){
		
			if(n.checked){
				check_val.push(n.value)
			}else{
				check_val.splice($.inArray(n.value,check_val),1)
			}
		}
		
		//批量删除
		function deleteAll(){
			
			if(check_val==null||check_val ==''||check_val==undefined){
				alertx("请选中删除的货品基础信息");
				return false;
			}
			return confirmx('确认要删除该货品基础信息吗？',"${ctx}/ka/basicGoods/deleteAll?ids="+check_val);
		}
		
	</script>
</head>
<body>
	<ul class="nav nav-tabs">
		<li class="active"><a href="${ctx}/ka/basicGoods/">货品基础信息列表</a></li>
		<li><a href="${ctx}/ka/kaSupplierChoose/">添加供应商货品信息</a></li>
		<%-- <shiro:hasPermission name="ka:basicGoods:edit"><li><a href="${ctx}/ka/basicGoods/form">货品基础信息添加</a></li></shiro:hasPermission> --%>
	</ul>
	<form:form id="searchForm" modelAttribute="basicGoods" action="${ctx}/ka/basicGoods/" method="post" class="breadcrumb form-search">
		<input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
		<input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
		<ul class="ul-form">
			<li><label>供应商：</label>
				<form:select path="supplierId" id="supplierId" class="input-medium">
					<form:option value="" label="全部"/>
					<form:options items="${fns:getSupplier() }" itemLabel="label" itemValue="value" htmlEscape="false"/>
				</form:select>
			</li>
			<li><label>品类：</label>
				<form:select path="categoryId" class="input-medium required">
					<form:option value="" label="全部"/>
					<form:options items="${fns:getCategory() }" itemLabel="label" itemValue="value" htmlEscape="false"/>
				</form:select>
			</li>
			<li><label>货号：</label>
				<form:input path="productCode" htmlEscape="false" class="input-medium"/>
			</li>
			<li class="btns"><input id="btnSubmit" class="btn btn-primary" type="submit" value="查询"/></li>
			<li class="btns"><input id="btnSubmit" class="btn btn-primary" type="button" onclick="clearForm()" value="重置"/></li>
			<li class="clearfix"></li>
		</ul>
		<shiro:hasPermission name="ka:basicGoods:delete">
			</br>
			<ul class="ul-form">
				<li class="btns"><label></label><input id="btnDelete" class="btn btn-primary" type="button" onclick="deleteAll()" value="批量删除"/></li>
				<li class="clearfix"></li>
			</ul>
		</shiro:hasPermission>	
	</form:form>
	<sys:message content="${message}"/>
	<table id="contentTable" class="table table-striped table-bordered table-condensed">
		<thead>
			<tr>
				<th><input type="checkbox" name="ck" onclick="selectAll(this)"></th>
				<th>品类</th>
				<th>货号</th>
				<th>供应商</th>
				<th>尺码</th>
				<th>颜色</th>
				<th>入库价格(默认值)</th>
				<th>销售价格(默认值)</th>
				<shiro:hasPermission name="ka:basicGoods:edit"><th>操作</th></shiro:hasPermission>
			</tr>
		</thead>
		<tbody>
		<c:forEach items="${page.list}" var="basicGoods">
			<tr>
				<td>
					<input type="checkbox" value ="${basicGoods.id }" onclick="check(this)">
				</td>
				<td>
					<a href="${ctx}/ka/basicGoods/form?id=${basicGoods.id}">
						${basicGoods.categoryName}
					</a>	
				</td>
				<td>
					${basicGoods.productCode}
				</td>
				<td>
					${basicGoods.supplierName}
				</td>
				<td>
					${basicGoods.sizeName}
				</td>
				<td>
					${basicGoods.colorName}
				</td>
				<td>
					${basicGoods.instockPrice}
				</td>
				<td>
					${basicGoods.salePrice}
				</td>
				<td>
    				<shiro:hasPermission name="ka:basicGoods:edit"><a href="${ctx}/ka/basicGoods/form?id=${basicGoods.id}">修改</a></shiro:hasPermission>
					<shiro:hasPermission name="ka:basicGoods:delete"><a href="${ctx}/ka/basicGoods/delete?id=${basicGoods.id}" onclick="return confirmx('确认要删除该货品基础信息吗？', this.href)">删除</a></shiro:hasPermission>
				</td>
			</tr>
		</c:forEach>
		</tbody>
	</table>
	<div class="pagination">${page}</div>
</body>
</html>